package com.example.controller;

import com.example.entity.FlightInfo;
import com.example.entity.RestBean;
import com.example.service.FlightService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/flights")
public class FlightController {
    @DubboReference
    private FlightService flightService;

    @GetMapping("/list")
    public RestBean<List<FlightInfo>> searchFlights(@RequestParam String from,
                                                    @RequestParam String to,
                                                    @RequestParam String departureDate,
                                                    @RequestParam String before) {
        System.out.println(1);
        return RestBean.success(flightService.queryByCondition(from, to, departureDate, before));
    }
}


